package com.zhentao.controller;

import com.zhentao.classManager.dto.ExaminationDto;
import com.zhentao.classManager.dto.SAnswerDto;
import com.zhentao.classManager.pojo.vo.PaperInfoVo;
import com.zhentao.result.Result;
import com.zhentao.service.SClassService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Resource
    private SClassService sClassService;

    //根据学生的班级编号查询此班级的考试信息
    @PostMapping("/classExaminationInfo")
    public Result classExaminationInfo(@RequestBody ExaminationDto examinationDto){
        Result result = sClassService.classExaminationInfo(examinationDto);
        return result;
    }

    //通过考试id查询考试题目
    @GetMapping("/examinationQuestion/{examinationId}")
    public Result examinationQuestion(@PathVariable("examinationId") Integer examinationId){
        Result result = sClassService.examinationQuestion(examinationId);
        return result;
    }

    //自动判卷实现
     @PostMapping("/autoMarking")
     public Result autoMarking(@RequestBody List<PaperInfoVo> paperInfoVos){
         Result result = sClassService.autoMarking(paperInfoVos);
         return result;
     }

     //查询历史考试信息
     @PostMapping("/historyExaminationInfo")
     public Result historyExaminationInfo(@RequestBody SAnswerDto sAnswerDto){
         Result result = sClassService.historyExaminationInfo(sAnswerDto);
         return result;
     }

     //查询历史考试考题正确答案以及学生答案
     @GetMapping("/historyExaminationQuestion/{userId}/{examinationId}")
     public Result historyExaminationQuestion(@PathVariable("userId") Integer userId,@PathVariable("examinationId") Integer examinationId){
         Result result = sClassService.historyExaminationQuestion(userId,examinationId);
         return result;
     }
}
